package com.hung.android;

/**
 * @author MANHHUNG
 * Báo cáo thực tập CDIT
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.json.JSONObject;

import android.app.Dialog;
import android.content.Intent;
import android.graphics.Color;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.Toast;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.OnMapClickListener;
import com.google.android.gms.maps.GoogleMap.OnMarkerClickListener;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.PolylineOptions;
import com.hung.android.place.ATMBaDinh;
import com.hung.android.place.ATMCauGiay;
import com.hung.android.place.ATMDongAnh;
import com.hung.android.place.ATMDongDa;
import com.hung.android.place.ATMGiaLam;
import com.hung.android.place.ATMHaDong;
import com.hung.android.place.ATMHaiBaTrung;
import com.hung.android.place.ATMHoanKIem;
import com.hung.android.place.ATMHoangMai;
import com.hung.android.place.ATMLongBien;
import com.hung.android.place.ATMTayHo;
import com.hung.android.place.ATMThanhXuan;
import com.hung.android.place.ATMTuLiem;
import com.hung.android.setting.AboutActivity;
import com.hung.android.setting.HelpActivity;

public class MainActivity extends FragmentActivity implements LocationListener {

	GoogleMap mGoogleMap;
	ArrayList<LatLng> mMarkerPoints;
	double mLatitude;
	double mLongitude;
	private String[] badinh = { "address", "Giảng Võ", "Kim Mã", "Liễu Giai",
			"Nguyễn Trường Tộ", "Trúc Bạch", "Giang Văn Minh", "Thành Công" };
	private String[] caugiay = { "address", "Trần Duy Hưng", "Hoàn Quốc Việt" };
	private String[] donganh = { "address", "Võng La", "TT.Đông Anh" };
	private String[] dongda = { "address", "Nguyễn Chí Thanh", "Khâm Thiên",
			"Cát Linh", "Nguyễn Thái Học", "Đông Tác", "Chùa Bộc", "Thái Hà",
			"Láng Thượng", "Láng Hạ" };
	private String[] gialam = { "address", "Phú Thị" };
	private String[] hadong = { "address", "Bà Triệu", "La Khê" };
	private String[] haibatrung = { "address", "Bà Triệu", "Nguyễn Du" };
	private String[] hoangmai = { "address", "Định Công", "Nguyễn An Ninh" };
	private String[] hoankiem = { "address", "Trần Hưng Đạo", "Lý Thường Kiệt" };
	private String[] longbien = { "address", "Gia Huy" };
	private String[] tayho = { "address", "Yên Phụ", "Xuân Diệu" };
	private String[] thanhxuan = { "address", "499 Nguyễn Trãi", "DH KHTN",
			"TX Trung", "Thượng Đình" };
	private String[] tuliem = { "address", "Phạm Hùng", "Lê Đức Thọ" };

	ArrayAdapter<String> adapter;
	private Spinner spinner;
	Spinner mSprPlaceType;

	String[] mPlaceType = null;
	String[] mPlaceTypeName = null;

	LatLng current;

	// TextView tvDistanceDuration;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		mPlaceType = getResources().getStringArray(R.array.place_type);

		// Array of place type names
		mPlaceTypeName = getResources().getStringArray(R.array.place_type_name);

		// Creating an array adapter with an array of Place types
		// to populate the spinner
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_dropdown_item, mPlaceTypeName);

		// Getting reference to the Spinner
		mSprPlaceType = (Spinner) findViewById(R.id.snplace);

		// Setting adapter on Spinner to set place types
		mSprPlaceType.setAdapter(adapter);

		Button btnFind;

		// Getting reference to Find Button
		btnFind = (Button) findViewById(R.id.btn_find);

		// Getting Google Play availability status
		int status = GooglePlayServicesUtil
				.isGooglePlayServicesAvailable(getBaseContext());

		spinner = (Spinner) findViewById(R.id.spr_place_type);
		// adapter = new ArrayAdapter<String>(MainActivity.this,
		// android.R.layout.simple_spinner_item, array);
		// spinner.setAdapter(adapter);

		// tvDistanceDuration = (TextView) findViewById(R.id.tv_distance_time);

		// Getting Google Play availability status
		// int status = GooglePlayServicesUtil
		// .isGooglePlayServicesAvailable(getBaseContext());

		if (status != ConnectionResult.SUCCESS) { // Google Play Services are
													// not available

			int requestCode = 10;
			Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this,
					requestCode);
			dialog.show();

		} else { // Google Play Services are available

			// Initializing
			mMarkerPoints = new ArrayList<LatLng>();

			// Getting reference to SupportMapFragment of the activity_main
			SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager()
					.findFragmentById(R.id.map);

			// Getting Map for the SupportMapFragment
			mGoogleMap = fm.getMap();

			// Enable MyLocation Button in the Map
			mGoogleMap.setMyLocationEnabled(true);

			// Getting LocationManager object from System Service
			// LOCATION_SERVICE
			LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

			// Creating a criteria object to retrieve provider
			Criteria criteria = new Criteria();

			// Getting the name of the best provider
			String provider = locationManager.getBestProvider(criteria, true);

			// Getting Current Location From GPS
			Location location = locationManager.getLastKnownLocation(provider);

			current = new LatLng(location.getLatitude(),
					location.getLongitude());
			mMarkerPoints.add(current);

			if (location != null) {
				onLocationChanged(location);
			}

			locationManager.requestLocationUpdates(provider, 20000, 0, this);

			// Setting onclick event listener for the map
			mGoogleMap.setOnMapClickListener(new OnMapClickListener() {

				@Override
				public void onMapClick(LatLng point) {

					// Already map contain destination location
					if (mMarkerPoints.size() > 1) {

						FragmentManager fm = getSupportFragmentManager();
						mMarkerPoints.clear();
						mGoogleMap.clear();
						LatLng startPoint = new LatLng(mLatitude, mLongitude);
						drawMarker(startPoint, null);
					}

					drawMarker(point, null);

					// Checks, whether start and end locations are captured
					if (mMarkerPoints.size() >= 2) {
						LatLng origin = mMarkerPoints.get(0);
						LatLng dest = mMarkerPoints.get(1);

						// Getting URL to the Google Directions API
						String url = getDirectionsUrl(origin, dest);

						DownloadTask downloadTask = new DownloadTask();

						// Start downloading json data from Google Directions
						// API
						downloadTask.execute(url);
					}
				}
			});

			btnFind.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {

					int selectedPosition = mSprPlaceType
							.getSelectedItemPosition();
					String type = mPlaceType[selectedPosition];

					StringBuilder sb = new StringBuilder(
							"https://maps.googleapis.com/maps/api/place/nearbysearch/json?");
					sb.append("location=" + mLatitude + "," + mLongitude);
					sb.append("&radius=5000");
					sb.append("&types=" + type);
					sb.append("&sensor=true");
					sb.append("&key=AIzaSyAOopl3WOuAh1K66me_xouRYTomlAfthMg");

					// Log.d(LOG_NAME, "" + sb);
					// Creating a new non-ui thread task to download Google
					// place json data
					PlacesTask placesTask = new PlacesTask();

					// Invokes the "doInBackground()" method of the class
					// PlaceTask
					placesTask.execute(sb.toString());

				}
			});

			mGoogleMap.setOnMarkerClickListener(new OnMarkerClickListener() {

				@Override
				public boolean onMarkerClick(Marker marker) {
					// TODO Auto-generated method stub
					LatLng dich = marker.getPosition();
					String url = getDirectionsUrl(current, dich);

					DownloadTask downloadTask = new DownloadTask();

					// Start downloading json data from Google Directions
					// API
					downloadTask.execute(url);

					return false;
				}
			});

		}
	}

	private String getDirectionsUrl(LatLng origin, LatLng dest) {

		// Origin of route
		String str_origin = "origin=" + origin.latitude + ","
				+ origin.longitude;

		// Destination of route
		String str_dest = "destination=" + dest.latitude + "," + dest.longitude;

		// Sensor enabled
		String sensor = "sensor=false";

		// Building the parameters to the web service
		String parameters = str_origin + "&" + str_dest + "&" + sensor;

		// Output format
		String output = "json";

		// Building the url to the web service
		String url = "https://maps.googleapis.com/maps/api/directions/"
				+ output + "?" + parameters;

		return url;
	}

	/** A method to download json data from url */
	private String downloadUrl(String strUrl) throws IOException {
		String data = "";
		InputStream iStream = null;
		HttpURLConnection urlConnection = null;
		try {
			URL url = new URL(strUrl);

			// Creating an http connection to communicate with url
			urlConnection = (HttpURLConnection) url.openConnection();

			// Connecting to url
			urlConnection.connect();

			// Reading data from url
			iStream = urlConnection.getInputStream();

			BufferedReader br = new BufferedReader(new InputStreamReader(
					iStream));

			StringBuffer sb = new StringBuffer();

			String line = "";
			while ((line = br.readLine()) != null) {
				sb.append(line);
			}

			data = sb.toString();

			br.close();

		} catch (Exception e) {
			Log.d("Exception while downloading url", e.toString());
		} finally {
			iStream.close();
			urlConnection.disconnect();
		}
		return data;
	}

	/** A class to download data from Google Directions URL */
	private class DownloadTask extends AsyncTask<String, Void, String> {

		// Downloading data in non-ui thread
		@Override
		protected String doInBackground(String... url) {

			// For storing data from web service
			String data = "";

			try {
				// Fetching the data from web service
				data = downloadUrl(url[0]);
			} catch (Exception e) {
				Log.d("Background Task", e.toString());
			}
			return data;
		}

		// Executes in UI thread, after the execution of
		// doInBackground()
		@Override
		protected void onPostExecute(String result) {
			super.onPostExecute(result);

			ParserTask parserTask = new ParserTask();

			// Invokes the thread for parsing the JSON data
			parserTask.execute(result);

		}
	}

	private class PlacesTask extends AsyncTask<String, Integer, String> {

		String data = null;

		// Invoked by execute() method of this object
		@Override
		protected String doInBackground(String... url) {
			try {
				data = downloadUrl(url[0]);
			} catch (Exception e) {
				Log.d("Background Task", e.toString());
			}
			return data;
		}

		// Executed after the complete execution of doInBackground() method
		@Override
		protected void onPostExecute(String result) {
			ParserTask2 parserTask2 = new ParserTask2();

			// Start parsing the Google places in JSON format
			// Invokes the "doInBackground()" method of the class ParseTask
			parserTask2.execute(result);
		}

	}

	/** A class to parse the Google Directions in JSON format */
	private class ParserTask extends
			AsyncTask<String, Integer, List<List<HashMap<String, String>>>> {

		// Parsing the data in non-ui thread
		@Override
		protected List<List<HashMap<String, String>>> doInBackground(
				String... jsonData) {

			JSONObject jObject;
			List<List<HashMap<String, String>>> routes = null;

			try {
				jObject = new JSONObject(jsonData[0]);
				DirectionsJSONParser parser = new DirectionsJSONParser();

				// Starts parsing data
				routes = parser.parse(jObject);
			} catch (Exception e) {
				e.printStackTrace();
			}
			return routes;
		}

		// Executes in UI thread, after the parsing process
		@Override
		protected void onPostExecute(List<List<HashMap<String, String>>> result) {
			ArrayList<LatLng> points = null;
			PolylineOptions lineOptions = null;
			MarkerOptions markerOptions = new MarkerOptions();
			String distance = "";
			String duration = "";

			if (result.size() < 1) {
				Toast.makeText(getBaseContext(), "No Points",
						Toast.LENGTH_SHORT).show();
				return;
			}

			// Traversing through all the routes
			for (int i = 0; i < result.size(); i++) {
				points = new ArrayList<LatLng>();
				lineOptions = new PolylineOptions();

				// Fetching i-th route
				List<HashMap<String, String>> path = result.get(i);

				// Fetching all the points in i-th route
				for (int j = 0; j < path.size(); j++) {
					HashMap<String, String> point = path.get(j);

					if (j == 0) { // Get distance from the list
						distance = (String) point.get("distance");
						continue;
					} else if (j == 1) { // Get duration from the list
						duration = (String) point.get("duration");
						continue;
					}

					double lat = Double.parseDouble(point.get("lat"));
					double lng = Double.parseDouble(point.get("lng"));
					LatLng position = new LatLng(lat, lng);

					points.add(position);
				}

				// Adding all the points in the route to LineOptions
				lineOptions.addAll(points);
				lineOptions.width(2);
				lineOptions.color(Color.RED);
			}

			// tvDistanceDuration.setText("Distance:" + distance + ", Duration:"
			// + duration);

			// Drawing polyline in the Google Map for the i-th route
			mGoogleMap.addPolyline(lineOptions);
		}
	}

	/** A class to parse the Google Places in JSON format */
	private class ParserTask2 extends
			AsyncTask<String, Integer, List<HashMap<String, String>>> {

		JSONObject jObject;

		// Invoked by execute() method of this object
		@Override
		protected List<HashMap<String, String>> doInBackground(
				String... jsonData) {

			List<HashMap<String, String>> places = null;
			PlaceJSONParser placeJsonParser = new PlaceJSONParser();

			try {
				jObject = new JSONObject(jsonData[0]);

				/** Getting the parsed data as a List construct */
				places = placeJsonParser.parse(jObject);

			} catch (Exception e) {
				Log.d("Exception", e.toString());
			}
			return places;
		}

		// Executed after the complete execution of doInBackground() method
		@Override
		protected void onPostExecute(List<HashMap<String, String>> list) {

			// Clears all the existing markers
			mGoogleMap.clear();

			for (int i = 0; i < list.size(); i++) {

				// Creating a marker
				MarkerOptions markerOptions = new MarkerOptions();

				// Getting a place from the places list
				HashMap<String, String> hmPlace = list.get(i);

				// Getting latitude of the place
				double lat = Double.parseDouble(hmPlace.get("lat"));

				// Getting longitude of the place
				double lng = Double.parseDouble(hmPlace.get("lng"));

				// Getting name
				String name = hmPlace.get("place_name");

				// Getting vicinity
				String vicinity = hmPlace.get("vicinity");

				LatLng latLng = new LatLng(lat, lng);

				// Setting the position for the marker
				markerOptions.position(latLng);

				// Setting the title for the marker.
				// This will be displayed on taping the marker
				markerOptions.title(name + " : " + vicinity);

				// Placing a marker on the touched position
				mGoogleMap.addMarker(markerOptions);

			}

		}

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	private void drawMarker(LatLng point, String snippet) {
		mMarkerPoints.add(point);

		// Creating MarkerOptions
		MarkerOptions options = new MarkerOptions();

		// Setting the position of the marker
		options.position(point);
		options.title("^_^");
		options.snippet(snippet);

		/**
		 * For the start location, the color of marker is GREEN and for the end
		 * location, the color of marker is RED.
		 */

		if (mMarkerPoints.size() == 1) {
			options.icon(BitmapDescriptorFactory
					.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
		} else if (mMarkerPoints.size() == 2) {
			options.icon(BitmapDescriptorFactory
					.defaultMarker(BitmapDescriptorFactory.HUE_RED));

		}

		// options.icon(BitmapDescriptorFactory.fromResource(R.drawable.atms));

		// Add new marker to the Google Map Android API V2
		mGoogleMap.addMarker(options);
	}

	@Override
	public void onLocationChanged(Location location) {
		// Draw the marker, if destination location is not set
		if (mMarkerPoints.size() < 2) {

			mLatitude = location.getLatitude();
			mLongitude = location.getLongitude();
			LatLng point = new LatLng(mLatitude, mLongitude);

			mGoogleMap.moveCamera(CameraUpdateFactory.newLatLng(point));
			mGoogleMap.animateCamera(CameraUpdateFactory.zoomTo(12));

			drawMarker(point, null);
		}

	}

	@Override
	public void onProviderDisabled(String provider) {
		// TODO Auto-generated method stub
	}

	@Override
	public void onProviderEnabled(String provider) {
		// TODO Auto-generated method stub
	}

	@Override
	public void onStatusChanged(String provider, int status, Bundle extras) {
		// TODO Auto-generated method stub
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		spinner = (Spinner) findViewById(R.id.spr_place_type);

		switch (item.getItemId()) {

		case R.id.menu_style:

			break;
		case R.id.snormal:
			mGoogleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
			break;
		case R.id.ssate:
			mGoogleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
			break;
		case R.id.sterain:
			mGoogleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
			break;

		case R.id.menu_help:
			Intent intenthelp = new Intent(MainActivity.this,
					HelpActivity.class);
			startActivity(intenthelp);
			break;
		case R.id.about:
			Intent intent1 = new Intent(MainActivity.this, AboutActivity.class);
			startActivity(intent1);

			break;

		case R.id.all:
			mGoogleMap.clear();

			drawMarker(ATMBaDinh.giangvanminh,
					"85 Giang Văn Minh, Đội Cấn, Ba Đình, Hà Nội, Việt Nam");
			drawMarker(ATMBaDinh.giangvo,
					"148 Giảng Võ, Ba Đình, Hà Nội, Việt Nam");
			drawMarker(ATMBaDinh.kimma,
					"649 Kim Mã, Ba Đình, Hà Nội, Việt Nam‎");
			drawMarker(ATMBaDinh.lieugiai,
					"Đội Cấn, Liễu Giai, Ba Đình, Hà Nội, Việt Nam‎");
			drawMarker(ATMBaDinh.nguyentruongto,
					"55 Nguyễn Trường Tộ, Nguyễn Trung Trực, Ba Đình, Hà Nội, Việt Nam");
			drawMarker(ATMBaDinh.thanhcong,
					"18 Láng Hạ, Thành Công, Ba Đình, Hà Nội, Việt Nam ");
			drawMarker(ATMBaDinh.trucbach,
					"80 Cửa Bắc, Trúc Bạch, Ba Đình, Hà Nội, Việt Nam");
			drawMarker(ATMCauGiay.hoangquocviet,
					"Hoàng Quốc Việt, Cầu Giấy, Hà Nội, Việt Nam");
			drawMarker(ATMCauGiay.tranduyhung,
					"35 Trần Duy Hưng, Trung Hoà, Cầu Giấy, Hà Nội, Việt Nam ");
			drawMarker(ATMDongAnh.ttda,
					"Quốc Lộ 3, tt. Đông Anh, Đông Anh, Hà Nội, Việt Nam ");
			drawMarker(ATMDongAnh.vongla,
					"Võng La, Đông Anh, Hà Nội, Việt Nam ");
			drawMarker(ATMDongDa.catlinh,
					"33 Cát Linh, Đống Đa, Hà Nội, Việt Nam ‎");
			drawMarker(ATMDongDa.chuboc,
					"Chùa Bộc, Trung Liệt, Đống Đa, Hà Nội, Việt Nam ‎");
			drawMarker(ATMDongDa.dongtac,
					"Đông Tác, Trung Tự, Đống Đa, Hà Nội, Việt Nam ‎");
			drawMarker(ATMDongDa.khamthien,
					"201 Khâm Thiên, Đống Đa, Hà Nội, Việt Nam ‎");
			drawMarker(ATMDongDa.langha,
					"4 Vũ Ngọc Phan, Láng Hạ, Đống Đa, Hà Nội, Việt Nam ‎");
			drawMarker(ATMDongDa.langthuong,
					"1176 Đường Láng, Láng Thượng, Đống Đa, Hà Nội, Việt Nam ‎");
			drawMarker(ATMDongDa.nguyenthaihoc,
					"87 Nguyễn Thái Học, Điện Biên, Đống Đa, Hà Nội, Việt Nam ‎");
			drawMarker(ATMDongDa.nguyetrithanh,
					"79 Nguyễn Chí Thanh, Đống Đa, Hà Nội, Việt Nam ‎");
			drawMarker(ATMDongDa.thaiha,
					"89 Thái Hà, Đống Đa, Hà Nội, Việt Nam ‎");
			drawMarker(ATMGiaLam.phuthi,
					"Dương Xá, Gia Lâm, Hà Nội, Việt Nam ‎");
			drawMarker(ATMHaDong.lakhe,
					"484 Quang Trung, La Khê, Hà Đông, Hà Nội, Việt Nam ‎");
			drawMarker(ATMHaDong.quangtrung, "25 Bà Triệu, Hà Nội, Việt Nam ‎");
			drawMarker(ATMHaiBaTrung.batrieu,
					"Bà Triệu, Hai Bà Trưng, Hà Nội, Việt Nam ‎");
			drawMarker(ATMHaiBaTrung.nguyendu,
					"10 Hồ Xuân Hương, Nguyễn Du, Hai Bà Trưng, Hà Nội, Việt Nam ‎");
			drawMarker(ATMHoangMai.dincong,
					"Định Công, Hoàng Mai, Hà Nội, Việt Nam ‎");
			drawMarker(ATMHoangMai.nguyenanninh,
					"106 Nguyễn An Ninh, Tương Mai, Hoàng Mai, Hà Nội, Việt Nam ‎");
			drawMarker(ATMHoanKIem.lythuongkiet,
					"27 Lý Thường Kiệt, Phan Chu Trinh, Hoàn Kiếm, Hà Nội, Việt Nam ‎");
			drawMarker(ATMHoanKIem.tranhungdao,
					"21 Trần Hưng Đạo, Phan Chu Trinh, Hoàn Kiếm, Hà Nội, Việt Nam ‎");
			drawMarker(ATMLongBien.giahuy,
					"200 Nguyễn Sơn, Gia Huy, Long Biên, Hà Nội, Việt Nam ‎");
			drawMarker(ATMTayHo.xuandieu,
					"51 Xuân Diệu, Quảng An, Tây Hồ, Hà Nội, Việt Nam ‎");
			drawMarker(ATMTayHo.yenphu,
					"62 Yên Phụ, Tây Hồ, Hà Nội, Việt Nam ‎");
			drawMarker(ATMThanhXuan.khtn,
					"336 Nguyễn Trãi, Thanh Xuân, Hà Nội, Việt Nam ‎");
			drawMarker(ATMThanhXuan.nguyentrai,
					"499 Nguyễn Trãi, Thanh Xuân, Hà Nội, Việt Nam ‎");
			drawMarker(ATMThanhXuan.thanhxuantrung,
					"277 Nguyễn Trãi, Thanh Xuân Trung, Thanh Xuân, Hà Nội, Việt Nam ‎");
			drawMarker(ATMThanhXuan.thuongdinh,
					"Nguyễn Trãi, Thượng Đình, Thanh Xuân, Hà Nội, Việt Nam ‎");
			drawMarker(ATMTuLiem.leductho,
					"Lê Đức Thọ, My Dinh 2, Từ Liêm, Hà Nội, Ha Tay, Việt Nam ‎");
			drawMarker(ATMTuLiem.phamhung,
					"18 Phạm Hùng, Từ Liêm, Hà Nội, Việt Nam ‎");

			break;
		case R.id.badinh:
			mGoogleMap.clear();

			drawMarker(ATMBaDinh.giangvanminh,
					"85 Giang Văn Minh, Đội Cấn, Ba Đình, Hà Nội, Việt Nam");
			drawMarker(ATMBaDinh.giangvo,
					"148 Giảng Võ, Ba Đình, Hà Nội, Việt Nam");
			drawMarker(ATMBaDinh.kimma,
					"649 Kim Mã, Ba Đình, Hà Nội, Việt Nam‎");
			drawMarker(ATMBaDinh.lieugiai,
					"Đội Cấn, Liễu Giai, Ba Đình, Hà Nội, Việt Nam‎");
			drawMarker(ATMBaDinh.nguyentruongto,
					"55 Nguyễn Trường Tộ, Nguyễn Trung Trực, Ba Đình, Hà Nội, Việt Nam");
			drawMarker(ATMBaDinh.thanhcong,
					"18 Láng Hạ, Thành Công, Ba Đình, Hà Nội, Việt Nam ");
			drawMarker(ATMBaDinh.trucbach,
					"80 Cửa Bắc, Trúc Bạch, Ba Đình, Hà Nội, Việt Nam");
			mMarkerPoints.clear();

			adapter = new ArrayAdapter<String>(MainActivity.this,
					android.R.layout.simple_spinner_item, badinh);
			spinner.setAdapter(adapter);
			spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

				@Override
				public void onItemSelected(AdapterView<?> parent, View arg1,
						int position, long id) {
					// TODO Auto-generated method stub
					switch (position) {
					case 0:
						Toast.makeText(MainActivity.this, "chọn điểm đặt ATM",
								Toast.LENGTH_SHORT).show();
						break;
					case 1:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMBaDinh.giangvo,
								"148 Giảng Võ, Ba Đình, Hà Nội, Việt Nam");
						String url = getDirectionsUrl(ATMBaDinh.giangvo,
								current);
						DownloadTask downloadTask = new DownloadTask();
						downloadTask.execute(url);

						break;
					case 2:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMBaDinh.kimma,
								"649 Kim Mã, Ba Đình, Hà Nội, Việt Nam‎");
						String url1 = getDirectionsUrl(current, ATMBaDinh.kimma);
						DownloadTask downloadTask1 = new DownloadTask();
						downloadTask1.execute(url1);
						break;

					case 3:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMBaDinh.lieugiai,
								"Đội Cấn, Liễu Giai, Ba Đình, Hà Nội, Việt Nam‎");
						String url2 = getDirectionsUrl(current,
								ATMBaDinh.lieugiai);
						DownloadTask downloadTask2 = new DownloadTask();
						downloadTask2.execute(url2);
						break;
					case 4:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMBaDinh.nguyentruongto,
								"55 Nguyễn Trường Tộ, Nguyễn Trung Trực, Ba Đình, Hà Nội, Việt Nam");
						String url3 = getDirectionsUrl(current,
								ATMBaDinh.nguyentruongto);
						DownloadTask downloadTask3 = new DownloadTask();
						downloadTask3.execute(url3);
						break;
					case 5:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMBaDinh.trucbach,
								"80 Cửa Bắc, Trúc Bạch, Ba Đình, Hà Nội, Việt Nam");
						String url4 = getDirectionsUrl(current,
								ATMBaDinh.trucbach);
						DownloadTask downloadTask4 = new DownloadTask();
						downloadTask4.execute(url4);
						break;
					case 6:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMBaDinh.giangvanminh,
								"85 Giang Văn Minh, Đội Cấn, Ba Đình, Hà Nội, Việt Nam");
						String url5 = getDirectionsUrl(current,
								ATMBaDinh.giangvanminh);
						DownloadTask downloadTask5 = new DownloadTask();
						downloadTask5.execute(url5);
						break;
					case 7:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMBaDinh.thanhcong,
								"18 Láng Hạ, Thành Công, Ba Đình, Hà Nội, Việt Nam ");
						String url6 = getDirectionsUrl(current,
								ATMBaDinh.thanhcong);
						DownloadTask downloadTask6 = new DownloadTask();
						downloadTask6.execute(url6);
						break;

					default:

						break;
					}

				}

				@Override
				public void onNothingSelected(AdapterView<?> arg0) {
					// TODO Auto-generated method stub

				}
			});
			break;
		case R.id.caugiay:
			mGoogleMap.clear();
			drawMarker(ATMCauGiay.hoangquocviet,
					"Hoàng Quốc Việt, Cầu Giấy, Hà Nội, Việt Nam");
			drawMarker(ATMCauGiay.tranduyhung,
					"35 Trần Duy Hưng, Trung Hoà, Cầu Giấy, Hà Nội, Việt Nam ");

			adapter = new ArrayAdapter<String>(MainActivity.this,
					android.R.layout.simple_spinner_item, caugiay);
			spinner.setAdapter(adapter);
			spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

				@Override
				public void onItemSelected(AdapterView<?> parent, View arg1,
						int position, long arg3) {
					switch (position) {
					case 0:
						Toast.makeText(MainActivity.this, "chọn điểm đặt ATM",
								Toast.LENGTH_SHORT).show();
						break;
					case 1:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMCauGiay.tranduyhung,
								"35 Trần Duy Hưng, Trung Hoà, Cầu Giấy, Hà Nội, Việt Nam ");
						String url = getDirectionsUrl(ATMCauGiay.tranduyhung,
								current);
						DownloadTask downloadTask = new DownloadTask();
						downloadTask.execute(url);

						break;
					case 2:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMCauGiay.hoangquocviet,
								"Hoàng Quốc Việt, Cầu Giấy, Hà Nội, Việt Nam");
						String url1 = getDirectionsUrl(current,
								ATMCauGiay.hoangquocviet);
						DownloadTask downloadTask1 = new DownloadTask();
						downloadTask1.execute(url1);
						break;
					default:

						break;
					}

				}

				@Override
				public void onNothingSelected(AdapterView<?> arg0) {
					// TODO Auto-generated method stub

				}
			});
			break;
		case R.id.donganh:
			mGoogleMap.clear();
			drawMarker(ATMDongAnh.ttda,
					"Quốc Lộ 3, tt. Đông Anh, Đông Anh, Hà Nội, Việt Nam ");
			drawMarker(ATMDongAnh.vongla,
					"Võng La, Đông Anh, Hà Nội, Việt Nam ");

			adapter = new ArrayAdapter<String>(MainActivity.this,
					android.R.layout.simple_spinner_item, donganh);
			spinner.setAdapter(adapter);
			spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

				@Override
				public void onItemSelected(AdapterView<?> parent, View arg1,
						int position, long arg3) {
					switch (position) {
					case 0:
						Toast.makeText(MainActivity.this, "chọn điểm đặt ATM",
								Toast.LENGTH_SHORT).show();
						break;
					case 1:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMDongAnh.vongla,
								"Võng La, Đông Anh, Hà Nội, Việt Nam ");
						String url = getDirectionsUrl(ATMDongAnh.vongla,
								current);
						DownloadTask downloadTask = new DownloadTask();
						downloadTask.execute(url);

						break;
					case 2:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMDongAnh.ttda,
								"Quốc Lộ 3, tt. Đông Anh, Đông Anh, Hà Nội, Việt Nam ");
						String url1 = getDirectionsUrl(current, ATMDongAnh.ttda);
						DownloadTask downloadTask1 = new DownloadTask();
						downloadTask1.execute(url1);
						break;
					default:

						break;
					}
				}

				@Override
				public void onNothingSelected(AdapterView<?> arg0) {
					// TODO Auto-generated method stub

				}
			});

			break;
		case R.id.dongda:
			mGoogleMap.clear();
			drawMarker(ATMDongDa.catlinh,
					"33 Cát Linh, Đống Đa, Hà Nội, Việt Nam ‎");
			drawMarker(ATMDongDa.chuboc,
					"Chùa Bộc, Trung Liệt, Đống Đa, Hà Nội, Việt Nam ‎");
			drawMarker(ATMDongDa.dongtac,
					"Đông Tác, Trung Tự, Đống Đa, Hà Nội, Việt Nam ‎");
			drawMarker(ATMDongDa.khamthien,
					"201 Khâm Thiên, Đống Đa, Hà Nội, Việt Nam ‎");
			drawMarker(ATMDongDa.langha,
					"4 Vũ Ngọc Phan, Láng Hạ, Đống Đa, Hà Nội, Việt Nam ‎");
			drawMarker(ATMDongDa.langthuong,
					"1176 Đường Láng, Láng Thượng, Đống Đa, Hà Nội, Việt Nam ‎");
			drawMarker(ATMDongDa.nguyenthaihoc,
					"87 Nguyễn Thái Học, Điện Biên, Đống Đa, Hà Nội, Việt Nam ‎");
			drawMarker(ATMDongDa.nguyetrithanh,
					"79 Nguyễn Chí Thanh, Đống Đa, Hà Nội, Việt Nam ‎");
			drawMarker(ATMDongDa.thaiha,
					"89 Thái Hà, Đống Đa, Hà Nội, Việt Nam ‎");

			adapter = new ArrayAdapter<String>(MainActivity.this,
					android.R.layout.simple_spinner_item, dongda);
			spinner.setAdapter(adapter);
			spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

				@Override
				public void onItemSelected(AdapterView<?> parent, View arg1,
						int position, long arg3) {

					switch (position) {
					case 0:
						Toast.makeText(MainActivity.this, "chọn điểm đặt ATM",
								Toast.LENGTH_SHORT).show();
						break;
					case 1:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMDongDa.nguyetrithanh,
								"79 Nguyễn Chí Thanh, Đống Đa, Hà Nội, Việt Nam ‎");
						String url = getDirectionsUrl(ATMDongDa.nguyetrithanh,
								current);
						DownloadTask downloadTask = new DownloadTask();
						downloadTask.execute(url);

						break;
					case 2:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMDongDa.khamthien,
								"201 Khâm Thiên, Đống Đa, Hà Nội, Việt Nam ‎");
						String url1 = getDirectionsUrl(current,
								ATMDongDa.khamthien);
						DownloadTask downloadTask1 = new DownloadTask();
						downloadTask1.execute(url1);
						break;

					case 3:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMDongDa.catlinh,
								"33 Cát Linh, Đống Đa, Hà Nội, Việt Nam ‎");
						String url2 = getDirectionsUrl(current,
								ATMDongDa.catlinh);
						DownloadTask downloadTask2 = new DownloadTask();
						downloadTask2.execute(url2);
						break;
					case 4:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMDongDa.nguyenthaihoc,
								"87 Nguyễn Thái Học, Điện Biên, Đống Đa, Hà Nội, Việt Nam ‎");
						String url3 = getDirectionsUrl(current,
								ATMDongDa.nguyenthaihoc);
						DownloadTask downloadTask3 = new DownloadTask();
						downloadTask3.execute(url3);
						break;
					case 5:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMDongDa.dongtac,
								"Đông Tác, Trung Tự, Đống Đa, Hà Nội, Việt Nam ‎");
						String url4 = getDirectionsUrl(current,
								ATMDongDa.dongtac);
						DownloadTask downloadTask4 = new DownloadTask();
						downloadTask4.execute(url4);
						break;
					case 6:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMDongDa.chuboc,
								"Chùa Bộc, Trung Liệt, Đống Đa, Hà Nội, Việt Nam ‎");
						String url5 = getDirectionsUrl(current,
								ATMDongDa.chuboc);
						DownloadTask downloadTask5 = new DownloadTask();
						downloadTask5.execute(url5);
						break;
					case 7:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMDongDa.thaiha,
								"89 Thái Hà, Đống Đa, Hà Nội, Việt Nam ‎");
						String url6 = getDirectionsUrl(current,
								ATMDongDa.thaiha);
						DownloadTask downloadTask6 = new DownloadTask();
						downloadTask6.execute(url6);
						break;
					case 8:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMDongDa.langthuong,
								"1176 Đường Láng, Láng Thượng, Đống Đa, Hà Nội, Việt Nam ‎");
						String url7 = getDirectionsUrl(current,
								ATMDongDa.langthuong);
						DownloadTask downloadTask7 = new DownloadTask();
						downloadTask7.execute(url7);
						break;
					case 9:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMDongDa.langha,
								"4 Vũ Ngọc Phan, Láng Hạ, Đống Đa, Hà Nội, Việt Nam ‎");
						String url8 = getDirectionsUrl(current,
								ATMDongDa.langha);
						DownloadTask downloadTask8 = new DownloadTask();
						downloadTask8.execute(url8);
						break;

					default:

						break;
					}
				}

				@Override
				public void onNothingSelected(AdapterView<?> arg0) {
					// TODO Auto-generated method stub

				}
			});

			break;
		case R.id.gialam:
			mGoogleMap.clear();
			drawMarker(ATMGiaLam.phuthi,
					"Dương Xá, Gia Lâm, Hà Nội, Việt Nam ‎");

			adapter = new ArrayAdapter<String>(MainActivity.this,
					android.R.layout.simple_spinner_item, gialam);
			spinner.setAdapter(adapter);
			spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

				@Override
				public void onItemSelected(AdapterView<?> parent, View arg1,
						int position, long arg3) {
					switch (position) {
					case 0:
						Toast.makeText(MainActivity.this, "chọn điểm đặt ATM",
								Toast.LENGTH_SHORT).show();
						break;
					case 1:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMGiaLam.phuthi,
								"Dương Xá, Gia Lâm, Hà Nội, Việt Nam ‎");
						String url = getDirectionsUrl(ATMGiaLam.phuthi, current);
						DownloadTask downloadTask = new DownloadTask();
						downloadTask.execute(url);

						break;

					default:

						break;
					}

				}

				@Override
				public void onNothingSelected(AdapterView<?> arg0) {
					// TODO Auto-generated method stub

				}
			});

			break;
		case R.id.hadong:
			mGoogleMap.clear();

			drawMarker(ATMHaDong.lakhe,
					"484 Quang Trung, La Khê, Hà Đông, Hà Nội, Việt Nam ‎");
			drawMarker(ATMHaDong.quangtrung, "25 Bà Triệu, Hà Nội, Việt Nam ‎");

			adapter = new ArrayAdapter<String>(MainActivity.this,
					android.R.layout.simple_spinner_item, hadong);
			spinner.setAdapter(adapter);
			spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

				@Override
				public void onItemSelected(AdapterView<?> parent, View arg1,
						int position, long arg3) {
					switch (position) {
					case 0:
						Toast.makeText(MainActivity.this, "chọn điểm đặt ATM",
								Toast.LENGTH_SHORT).show();
						break;
					case 1:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMHaDong.quangtrung,
								"25 Bà Triệu, Hà Nội, Việt Nam ‎");
						String url = getDirectionsUrl(ATMHaDong.quangtrung,
								current);
						DownloadTask downloadTask = new DownloadTask();
						downloadTask.execute(url);

						break;
					case 2:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMHaDong.lakhe,
								"484 Quang Trung, La Khê, Hà Đông, Hà Nội, Việt Nam ‎");
						String url1 = getDirectionsUrl(current, ATMHaDong.lakhe);
						DownloadTask downloadTask1 = new DownloadTask();
						downloadTask1.execute(url1);
						break;
					default:

						break;
					}
				}

				@Override
				public void onNothingSelected(AdapterView<?> arg0) {
					// TODO Auto-generated method stub

				}
			});

			break;
		case R.id.haibatrung:
			mGoogleMap.clear();
			drawMarker(ATMHaiBaTrung.batrieu,
					"Bà Triệu, Hai Bà Trưng, Hà Nội, Việt Nam ‎");
			drawMarker(ATMHaiBaTrung.nguyendu,
					"10 Hồ Xuân Hương, Nguyễn Du, Hai Bà Trưng, Hà Nội, Việt Nam ‎");

			adapter = new ArrayAdapter<String>(MainActivity.this,
					android.R.layout.simple_spinner_item, haibatrung);
			spinner.setAdapter(adapter);
			spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

				@Override
				public void onItemSelected(AdapterView<?> parent, View arg1,
						int position, long arg3) {
					switch (position) {
					case 0:
						Toast.makeText(MainActivity.this, "chọn điểm đặt ATM",
								Toast.LENGTH_SHORT).show();
						break;
					case 1:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMHaiBaTrung.batrieu,
								"Bà Triệu, Hai Bà Trưng, Hà Nội, Việt Nam ‎");

						String url = getDirectionsUrl(ATMHaiBaTrung.batrieu,
								current);
						DownloadTask downloadTask = new DownloadTask();
						downloadTask.execute(url);

						break;
					case 2:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMHaiBaTrung.nguyendu,
								"10 Hồ Xuân Hương, Nguyễn Du, Hai Bà Trưng, Hà Nội, Việt Nam ‎");
						String url1 = getDirectionsUrl(current,
								ATMHaiBaTrung.nguyendu);
						DownloadTask downloadTask1 = new DownloadTask();
						downloadTask1.execute(url1);
						break;
					default:

						break;
					}

				}

				@Override
				public void onNothingSelected(AdapterView<?> arg0) {
					// TODO Auto-generated method stub

				}
			});

			break;
		case R.id.hoangmai:
			mGoogleMap.clear();
			drawMarker(ATMHoangMai.dincong,
					"Định Công, Hoàng Mai, Hà Nội, Việt Nam ‎");
			drawMarker(ATMHoangMai.nguyenanninh,
					"106 Nguyễn An Ninh, Tương Mai, Hoàng Mai, Hà Nội, Việt Nam ‎");

			adapter = new ArrayAdapter<String>(MainActivity.this,
					android.R.layout.simple_spinner_item, hoangmai);
			spinner.setAdapter(adapter);
			spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

				@Override
				public void onItemSelected(AdapterView<?> parent, View arg1,
						int position, long arg3) {
					switch (position) {
					case 0:
						Toast.makeText(MainActivity.this, "chọn điểm đặt ATM",
								Toast.LENGTH_SHORT).show();
						break;
					case 1:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMHoangMai.dincong,
								"Định Công, Hoàng Mai, Hà Nội, Việt Nam ‎");
						String url = getDirectionsUrl(ATMHoangMai.dincong,
								current);
						DownloadTask downloadTask = new DownloadTask();
						downloadTask.execute(url);

						break;
					case 2:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMHoangMai.nguyenanninh,
								"106 Nguyễn An Ninh, Tương Mai, Hoàng Mai, Hà Nội, Việt Nam ‎");
						String url1 = getDirectionsUrl(current,
								ATMHoangMai.nguyenanninh);
						DownloadTask downloadTask1 = new DownloadTask();
						downloadTask1.execute(url1);
						break;
					default:

						break;
					}
				}

				@Override
				public void onNothingSelected(AdapterView<?> arg0) {
					// TODO Auto-generated method stub

				}
			});

			break;
		case R.id.hoankiem:
			mGoogleMap.clear();
			drawMarker(ATMHoanKIem.lythuongkiet,
					"27 Lý Thường Kiệt, Phan Chu Trinh, Hoàn Kiếm, Hà Nội, Việt Nam ‎");
			drawMarker(ATMHoanKIem.tranhungdao,
					"21 Trần Hưng Đạo, Phan Chu Trinh, Hoàn Kiếm, Hà Nội, Việt Nam ‎");

			adapter = new ArrayAdapter<String>(MainActivity.this,
					android.R.layout.simple_spinner_item, hoankiem);
			spinner.setAdapter(adapter);
			spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

				@Override
				public void onItemSelected(AdapterView<?> parent, View arg1,
						int position, long arg3) {
					switch (position) {
					case 0:
						Toast.makeText(MainActivity.this, "chọn điểm đặt ATM",
								Toast.LENGTH_SHORT).show();
						break;
					case 1:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMHoanKIem.tranhungdao,
								"21 Trần Hưng Đạo, Phan Chu Trinh, Hoàn Kiếm, Hà Nội, Việt Nam ‎");
						String url = getDirectionsUrl(ATMHoanKIem.tranhungdao,
								current);
						DownloadTask downloadTask = new DownloadTask();
						downloadTask.execute(url);

						break;
					case 2:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMHoanKIem.lythuongkiet,
								"27 Lý Thường Kiệt, Phan Chu Trinh, Hoàn Kiếm, Hà Nội, Việt Nam ‎");
						String url1 = getDirectionsUrl(current,
								ATMHoanKIem.lythuongkiet);
						DownloadTask downloadTask1 = new DownloadTask();
						downloadTask1.execute(url1);
						break;
					default:

						break;
					}
				}

				@Override
				public void onNothingSelected(AdapterView<?> arg0) {
					// TODO Auto-generated method stub

				}
			});

			break;
		case R.id.longbien:
			mGoogleMap.clear();
			drawMarker(ATMLongBien.giahuy,
					"200 Nguyễn Sơn, Gia Huy, Long Biên, Hà Nội, Việt Nam ‎");

			adapter = new ArrayAdapter<String>(MainActivity.this,
					android.R.layout.simple_spinner_item, longbien);
			spinner.setAdapter(adapter);
			spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

				@Override
				public void onItemSelected(AdapterView<?> parent, View arg1,
						int position, long arg3) {
					switch (position) {
					case 0:
						Toast.makeText(MainActivity.this, "chọn điểm đặt ATM",
								Toast.LENGTH_SHORT).show();
						break;
					case 1:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMLongBien.giahuy,
								"200 Nguyễn Sơn, Gia Huy, Long Biên, Hà Nội, Việt Nam ‎");
						String url = getDirectionsUrl(ATMGiaLam.phuthi, current);
						DownloadTask downloadTask = new DownloadTask();
						downloadTask.execute(url);

						break;

					default:

						break;
					}
				}

				@Override
				public void onNothingSelected(AdapterView<?> arg0) {
					// TODO Auto-generated method stub

				}
			});

			break;
		case R.id.tayho:
			mGoogleMap.clear();
			drawMarker(ATMTayHo.xuandieu,
					"51 Xuân Diệu, Quảng An, Tây Hồ, Hà Nội, Việt Nam ‎");
			drawMarker(ATMTayHo.yenphu,
					"62 Yên Phụ, Tây Hồ, Hà Nội, Việt Nam ‎");

			adapter = new ArrayAdapter<String>(MainActivity.this,
					android.R.layout.simple_spinner_item, tayho);
			spinner.setAdapter(adapter);
			spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

				@Override
				public void onItemSelected(AdapterView<?> parent, View arg1,
						int position, long arg3) {
					switch (position) {
					case 0:
						Toast.makeText(MainActivity.this, "chọn điểm đặt ATM",
								Toast.LENGTH_SHORT).show();
						break;
					case 1:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMTayHo.yenphu,
								"62 Yên Phụ, Tây Hồ, Hà Nội, Việt Nam ‎");
						String url = getDirectionsUrl(ATMTayHo.yenphu, current);
						DownloadTask downloadTask = new DownloadTask();
						downloadTask.execute(url);

						break;
					case 2:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMTayHo.xuandieu,
								"51 Xuân Diệu, Quảng An, Tây Hồ, Hà Nội, Việt Nam ‎");
						String url1 = getDirectionsUrl(current,
								ATMTayHo.xuandieu);
						DownloadTask downloadTask1 = new DownloadTask();
						downloadTask1.execute(url1);
						break;
					default:

						break;
					}

				}

				@Override
				public void onNothingSelected(AdapterView<?> arg0) {
					// TODO Auto-generated method stub

				}
			});

			break;
		case R.id.thanhxuan:
			mGoogleMap.clear();
			drawMarker(ATMThanhXuan.khtn,
					"336 Nguyễn Trãi, Thanh Xuân, Hà Nội, Việt Nam ‎");
			drawMarker(ATMThanhXuan.nguyentrai,
					"499 Nguyễn Trãi, Thanh Xuân, Hà Nội, Việt Nam ‎");
			drawMarker(ATMThanhXuan.thanhxuantrung,
					"277 Nguyễn Trãi, Thanh Xuân Trung, Thanh Xuân, Hà Nội, Việt Nam ‎");
			drawMarker(ATMThanhXuan.thuongdinh,
					"Nguyễn Trãi, Thượng Đình, Thanh Xuân, Hà Nội, Việt Nam ‎");

			adapter = new ArrayAdapter<String>(MainActivity.this,
					android.R.layout.simple_spinner_item, thanhxuan);
			spinner.setAdapter(adapter);
			spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

				@Override
				public void onItemSelected(AdapterView<?> parent, View arg1,
						int position, long arg3) {
					switch (position) {
					case 0:
						Toast.makeText(MainActivity.this, "chọn điểm đặt ATM",
								Toast.LENGTH_SHORT).show();
						break;
					case 1:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMThanhXuan.nguyentrai,
								"499 Nguyễn Trãi, Thanh Xuân, Hà Nội, Việt Nam ‎");
						String url = getDirectionsUrl(ATMThanhXuan.nguyentrai,
								current);
						DownloadTask downloadTask = new DownloadTask();
						downloadTask.execute(url);

						break;
					case 2:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMThanhXuan.khtn,
								"336 Nguyễn Trãi, Thanh Xuân, Hà Nội, Việt Nam ‎");
						String url1 = getDirectionsUrl(current,
								ATMThanhXuan.khtn);
						DownloadTask downloadTask1 = new DownloadTask();
						downloadTask1.execute(url1);
						break;

					case 3:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMThanhXuan.thanhxuantrung,
								"277 Nguyễn Trãi, Thanh Xuân Trung, Thanh Xuân, Hà Nội, Việt Nam ‎");
						String url2 = getDirectionsUrl(current,
								ATMThanhXuan.thanhxuantrung);
						DownloadTask downloadTask2 = new DownloadTask();
						downloadTask2.execute(url2);
						break;
					case 4:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMThanhXuan.thuongdinh,
								"Nguyễn Trãi, Thượng Đình, Thanh Xuân, Hà Nội, Việt Nam ‎");
						String url3 = getDirectionsUrl(current,
								ATMThanhXuan.thuongdinh);
						DownloadTask downloadTask3 = new DownloadTask();
						downloadTask3.execute(url3);
						break;

					default:

						break;
					}

				}

				@Override
				public void onNothingSelected(AdapterView<?> arg0) {
					// TODO Auto-generated method stub

				}
			});

			break;
		case R.id.tuliem:
			mGoogleMap.clear();
			drawMarker(ATMTuLiem.leductho,
					"Lê Đức Thọ, My Dinh 2, Từ Liêm, Hà Nội, Ha Tay, Việt Nam ‎");
			drawMarker(ATMTuLiem.minhkhai, "Minh Khai,Từ Liêm");
			drawMarker(ATMTuLiem.phamhung,
					"18 Phạm Hùng, Từ Liêm, Hà Nội, Việt Nam ‎");

			adapter = new ArrayAdapter<String>(MainActivity.this,
					android.R.layout.simple_spinner_item, tuliem);
			spinner.setAdapter(adapter);
			spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

				@Override
				public void onItemSelected(AdapterView<?> parent, View arg1,
						int position, long arg3) {
					switch (position) {
					case 0:
						Toast.makeText(MainActivity.this, "chọn điểm đặt ATM",
								Toast.LENGTH_SHORT).show();
						break;
					case 1:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMTuLiem.phamhung,
								"18 Phạm Hùng, Từ Liêm, Hà Nội, Việt Nam ‎");
						String url = getDirectionsUrl(ATMTuLiem.phamhung,
								current);
						DownloadTask downloadTask = new DownloadTask();
						downloadTask.execute(url);

						break;
					case 2:
						mGoogleMap.clear();
						mMarkerPoints.clear();
						drawMarker(ATMTuLiem.leductho,
								"Lê Đức Thọ, My Dinh 2, Từ Liêm, Hà Nội, Ha Tay, Việt Nam ‎");
						String url1 = getDirectionsUrl(current,
								ATMTuLiem.leductho);
						DownloadTask downloadTask1 = new DownloadTask();
						downloadTask1.execute(url1);
						break;

					default:

						break;
					}

				}

				@Override
				public void onNothingSelected(AdapterView<?> arg0) {
					// TODO Auto-generated method stub

				}
			});

			break;

		default:
			break;
		}

		return super.onOptionsItemSelected(item);
	}
}